<template>
  <div>
  <div class="inspection_evaluation">

    <el-form :model="checkForm" label-width="100px">
      <el-input v-if="false" v-model="checkForm.id"></el-input>
      <el-row>
        <el-col :span="4">
          <div class="col_label">审核结果</div>
        </el-col>
        <el-col :span="20">
          <div  class="col_view">
            <el-radio-group v-model="checkForm.checkStatus">
              <el-radio :label="1">通过</el-radio>
              <el-radio :label="-1">驳回</el-radio>
            </el-radio-group>
          </div>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="4">
          <div class="col_label">审核意见</div>
        </el-col>
        <el-col :span="20">
          <div  class="col_view">
            <el-input type="textarea" v-model="checkForm.checkOpinion"></el-input>
          </div>
        </el-col>
      </el-row>
  </el-form>


    <el-form :model="rfiViewData" style="margin:10px">
      <el-row>
        <el-col :span="4">
          <div class="col_label">反馈内容</div>
        </el-col>
        <el-col :span="20">
          <div  class="col_view">{{rfiViewData.feedbackComment}}</div>
        </el-col>
      </el-row>
    </el-form>
    <el-table :data="tableData5" style="width: 100%; margin: 16px;" border row-key="id" :expand-row-keys="expandRowkeys">
      <el-table-column type="expand">
        <template slot-scope="props">
          <expand-child :parentData="props.row" :ref="'expand-' + props.row.id"></expand-child>
        </template>
      </el-table-column>
     <el-table-column
        label="资料名称"
        prop="dataName">
      </el-table-column>
      <el-table-column
        label="作用域" :formatter="getScope"
        prop="actionScope">
      </el-table-column>
      <el-table-column
        label="认证" :formatter="getAptitude"
        prop="aptitudeFlag">
      </el-table-column>
    </el-table>

    <div style="margin-left:30px" class="el_submit" >
      <el-button type="primary" @click="sumitCheck(checkForm)">提交审批</el-button>
      <router-link to="/Index/Supplier/Rfi">
        <el-button type="primary">返回</el-button>
      </router-link>
    </div>
    </div>
  </div>
</template>

<style>
  .demo-table-expand {
    font-size: 0;
  }

  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }

  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 50%;
  }
</style>

<script>
  import expandChild from '@/components/vendormgt/rfi/vendor/childTable.vue';

  export default {
    data() {
      return {
        isShow: false,
        rfiItemId:'',
        vdRfiItemId:'',
        tableData5: [],
        childData: {},
        rfiViewData:{

        },
        checkForm: {
          checkStatus:1,
          checkOpinion: ''
        },
        expandRowkeys:[]
      }
    },
    components: {
      expandChild
    },
    mounted(){
      this.submitForm();
      this.getViewDetail();
    },
    methods: {
      submitForm() {
        this.rfiItemId = this.$route.query.id;
        this.axios.post(this.lib.config.host.vendorMgt + "/vendormgt/vsp/rfi/queryRfiItems/" + this.$route.query.rfiId, {}).then((response) => {
          debugger;
          console.log(response.data);
            this.tableData5 = response.data;
          })
          .catch(function (error) {
            console.log(error);
          });
      },
      getViewDetail() {
       this.axios.post(this.lib.config.host.vendorMgt + "/vendormgt/vsp/rfi/toItemView/" + this.$route.query.id)
          .then((response)=>{
            this.rfiViewData = response.data;
          })
          .catch((error)=>{
            console.log(error);
          });
      },
      sumitCheck(form){
        this.checkForm.id = this.rfiItemId
        this.axios.post(this.lib.config.host.vendorMgt + '/vendormgt/vsp/rfiitem/check', this.checkForm).then((res)=>{
          if(res.data.success == false){
            this.$message(res.data.message);
          }else{
            this.$router.push('/Index/Supplier/Rfi');
            this.$message('操作成功');
          }
          }).catch((e)=>{
              this.$message({
                type: 'info',
                message: '更新失败！'
              });
            });
      },
       getScope(value) {
        if(value.actionScope == 1){
            return '公司';
        }
        if(value.actionScope == 2){
            return '材料';
        }
        if(value.actionScope == 3){
            return '其它';
        }
      },
      getIndate(value) {
        if(value.indateFlag == 1){
            return '永久';
        }
        if(value.indateFlag == 2){
            return '过期失效';
        }
        if(value.indateFlag == 3){
            return '一次性';
        }        
      },
      getAptitude(value) {
        if(value.aptitudeFlag == 0){
            return '否';
        }
        if(value.aptitudeFlag == 1){
            return '是';
        }
      }
    }
  }
</script>
